﻿using System;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;

using NKestrelClient.Memcache;
using NKestrelClient.Kestrel;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            MemcachedClient.Setup("kestrel", new string[] { "127.0.0.1:22133" });

            var kestrel = new KestrelClient(MemcachedClient.GetInstance("kestrel"));

            var queue = Guid.NewGuid().ToString();

            using (var channel = kestrel.GetChannel(queue))
            {
                var data = channel.Get(queue);
                Debug.Assert(data == null);
                channel.Set(queue, Encoding.UTF8.GetBytes("qwerty"));
                channel.Set(queue, Encoding.UTF8.GetBytes("shai"));
                data = channel.Get(queue);
                Debug.Assert(Encoding.UTF8.GetString(data) == "qwerty");
                data = channel.Get(queue);
                Debug.Assert(Encoding.UTF8.GetString(data) == "shai");
                data = channel.Get(queue);
                Debug.Assert(data == null);
            }
        }
    }
}
